#include "thread.h"
#include "Class.h"
#include "cp_info.h"
#include <string>
#include "ExecuteEngine.h"
using namespace std;

void Thread::run(Class *javaClass, std::wstring methodName) {
	//find method
	for(int i = 0; i < javaClass->methods_count; i++) {
		short nameIndex = javaClass->methods[i]->name_index;
		if(((constant_utf8_info*)javaClass->constant_pool[nameIndex])->bytes == methodName) {
			Method *method = javaClass->methods[i];
			break;
		}
	}
	Frame *frame = new Frame();
	this->javaStack.push(frame);
	ExecuteEngine(javaClass, method, frame);
}